package casa.depesos.app.com.dlg;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import casa.depesos.app.com.databinding.DlgReadBinding;


public class ReadDlg extends FullScreenDlg {

    DlgReadBinding binding;
    String msg, cancel, ok;

    public ReadDlg setMsg(String info, String cancel, String ok) {
        msg = info;
        this.cancel = cancel;
        this.ok = ok;
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DlgReadBinding.inflate(inflater, container, false);
        binding.cancel.setOnClickListener(v -> dismiss());
        binding.ok.setOnClickListener(v -> dismiss(true, null));
        if (!TextUtils.isEmpty(msg)) {
            binding.tv.setText(msg);
        }
        if (!TextUtils.isEmpty(cancel)) {
            binding.cancel.setText(cancel);
        }
        if (!TextUtils.isEmpty(ok)) {
            binding.ok.setText(ok);
        }

        return binding.getRoot();
    }
}
